package cn.xqj.basic.config;

import cn.xqj.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                // 登录放行
                .excludePathPatterns("/login/**")
                // 注册放行
                .excludePathPatterns("/user/register/**")
                // 验证码放行
                .excludePathPatterns("/captcha/**")
                // 店铺入驻放行
                .excludePathPatterns("/shop/settle")
                // fastdfs图片上传放行
                .excludePathPatterns("/fastdfs")
                // 邮箱激活放行
                .excludePathPatterns("/logininfo/active, /shop/active")
                // swagger放行
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
    }
}
